using UnityEngine;
using StarseekerStuff;
using System.Linq;

public class Core : MonoBehaviour
{
    // private ExampleUI exampleUI;

    public void KillDeezBitches(Vector3 worldPos, float explosionRadius)
    {
        float radiusSqr = explosionRadius * explosionRadius;
        var actors = ActorManager.Instance.GetAllActors().ToList();

        foreach (var a in actors)
        {
            if (a == null || a.IsDead)
                continue;

            float distSqr = (worldPos - a.position).sqrMagnitude;
            if (distSqr <= radiusSqr)
            {
                ActorManager.Instance.RemoveActor(a);
            }
        }
    }

    void Start()
    {
        Debug.Log("TUXXEGO IS MY POOKIE");
        ButtonAsset fuckyou = new ButtonBuilder("bluenight")
            .SetName("Spawn BlueNight")
            .SetDescription("TUXXEGO IS MY POOKIE")
            .SetTab("spawning")
            .SetIcon(ModUtils.LoadSprite("BlueBox", "buttons/BlueNightIcon"))
            .SetType(CoolButton.ButtonType.Godpower)
            .SetGodpowerId("godpower_bluenight")
            .Build();

        AssetManager.Instance.buttons.Add(fuckyou);

        ButtonAsset nuke = new ButtonBuilder("nuke")
            .SetName("Spawn Nuke")
            .SetDescription("OMG MODERNBOX REFERENCE")
            .SetTab("disasters")
            .SetIcon(ModUtils.LoadSprite("BlueBox", "buttons/NukeIcon"))
            .SetType(CoolButton.ButtonType.Godpower)
            .SetGodpowerId("godpower_nuke")
            .Build();

        AssetManager.Instance.buttons.Add(nuke);

        GodpowerAsset oooh = new GodpowerBuilder("godpower_bluenight")
            .SetName("Summon BlueNight")
            .SetDescription("Spawns BlueNight at the target location.")
            .SetAction((pos, tile, power) =>
            {
                ActionLibrary.SpawnActor("bluenight", pos);
            })
            .Build();

        AssetManager.Instance.powers.Add(oooh);

         GodpowerAsset nukey = new GodpowerBuilder("godpower_nuke")
            .SetName("Summon Nuke")
            .SetDescription("Spawns Nuke at the target location.")
            .SetAction((pos, tile, power) =>
            {
               KillDeezBitches(pos, 600f);
            })
            .Build();

        AssetManager.Instance.powers.Add(nukey);

        ActorAsset bluenight = new ActorBuilder("bluenight")
            .SetName("BlueNight")
            .SetStat("health", 1000)
            .SetStat("speed", 2f)
            .SetStat("vision_range", 5f)
            .SetStat("attack_range", 1.1f)
            .SetStat("attack_damage", 20)
            .SetSprite(ModUtils.LoadSprite("BlueBox", "actors/bluenight/bluenight"))
            .SetSizeID("human_size")
            .SetSpeciesID("human_species")
            .AddBehavior(new CoreBehavior { AdultOnly = false })
            .AddBehavior(new ReproduceBehavior { detectionRange = 6f, AdultOnly = true })
            .AddBehavior(new WanderBehavior { roamRadius = 5f, AdultOnly = false })
            .AddBehavior(new ShitFuckTree { detectionRange = 40f, AdultOnly = true })
       //     .AddBehavior(new BabyBehavior { AdultOnly = false })
            .AddBehavior(new NationBehavior { AdultOnly = true })
            //   .AddBehavior(new DefensiveBehavior { AdultOnly = false })
            .AddBehavior(new ResourceGatherBehavior { detectionRange = 40f, AdultOnly = true })
            .Build();

       AssetManager.Instance.actors.Add(bluenight);

   //     exampleUI = gameObject.AddComponent<ExampleUI>();
    }
}